<template>
  <div class="item-wrapper">
    <van-cell-group>
      <template v-if="info.type == 1">
        <van-cell title="公司名称" title-class="tw">{{ info.name }}</van-cell>
      </template>
      <template v-if="info.type == 2">
        <van-cell title="姓名" title-class="tw">{{ info.name }}</van-cell>
      </template>
      <van-cell title="联系电话" title-class="tw">{{ info.mobile }}</van-cell>
      <van-cell title="地址" title-class="tw">{{ info.full_address }}</van-cell>
      <template v-if="info.type == 1">
        <van-cell title="营业执照">
          <template slot="label">
            <p v-for="item in info.license" :key="item">
              <img :src="item" class="img" />
            </p>
          </template>
        </van-cell>
      </template>
      <template v-if="info.type == 2">
        <van-cell title="身份证">
          <template slot="label">
            <p>
              <img :src="info.identity_1" />
            </p>
            <p>
              <img :src="info.identity_2" />
            </p>
          </template>
        </van-cell>
      </template>
    </van-cell-group>
  </div>
</template>

<script>
import { Toast } from "vant";
export default {
  props: {
    applyType: {
      type: String | Number,
      required: true
    }
  },
  data() {
    return {
      info: {}
    };
  },
  mounted() {
    this.getData();
  },
  methods: {
    getData: function() {
      const that = this;
      $http.get("plugin.operation.frontend.index.get-data", {basic_info: 0, category: this.applyType}, "加载中...")
        .then(function(response) {
          const { result, data, msg } = response
          if (result == 1) {
            if (data && data.info) {
              that.info = data.info;
            }
          } else {
            Toast(msg || "数据获取失败");
          }
        });
    }
  }
};
</script>

<style scoped lang="scss" rel="stylesheet/scss">
.item-wrapper {
  text-align: left;

  .tw {
    width: 100px!important;
    flex: none;
  }

  .img {
    max-width: 100%;
  }
}
</style>